<template>
  <div class="t-balance" avalonctrl="vmSettlement">
    <table cellspacing="0" class="list-wrap ">
      <tbody>
        <tr>
          <th style="width: 120px" class="txt-c ">	股票编码</th>
          <th style="width: 140px" class="txt-c ">	股票名称</th>
          <th style="width: 80px" class="txt-c ">股票价格</th>
          <th style="width: 80px" class="txt-c ">	建仓费</th>
          <th style="width: 80px" class="txt-c ">	创建金额</th>
          <th style="width: 110px" class="txt-c ">	统计递延费</th>
          <th style="width: 110px" class="txt-c ">	平仓价格</th>
          <th style="width: 110px" class="txt-c ">	收益</th>
        </tr>
        <tr v-for="(item,index) in history" :key="index">
          <td class="txt-c ">{{item.code | filtersName}}</td>
          <td class="txt-c ">{{item.name}}</td>
          <td class="txt-c ">{{item.price}}</td>
          <td class="txt-c ">{{item.cangfei}}</td>
          <td class="txt-c ">{{item.create_money}}</td>
          <td class="txt-c ">{{item.count_diyanfei}}</td>
          <td class="txt-c ">{{item.deal_money}}</td>
          <td class="txt-c ">{{item.profit}}</td>
        </tr>      
      </tbody>
    </table>
    <div class="pagination clearfix " style="">
      <ul class="clearfix " style="margin-right: 0">
        <li>
          <a @click="fy(-1)" style="transform:scale(-1)" title="上一页" class="page prev iconfont">&#xe611;</a>
        </li>

        <li style="line-height: 10px; height: 30px; vertical-align: middle">记录总数：<i style="color: red">{{all}}</i> &nbsp;&nbsp;页码： <i style="color: red">{{now}}</i>&nbsp;/&nbsp;{{last}}
        </li>
        <li>
          <a @click="fy(1)" title="下一页" class="page next iconfont">&#xe611;</a>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import Axios from "@/common/js/Axios";

export default {
  mounted(){
    this.getHistory(this.now);
  },
  data() {
    return {
      //总信息
      all:1,
      //当前页码
      now:1,
      // 总共页码
      last:1,
      history: [],
      //页脚
      page: 0,
      token:localStorage.getItem("Authorization")
    };
  },
  methods: {
    //翻页
    fy(v){      
      if(v == -1){
        this.getHistory(--this.now);
      }else{
        this.getHistory(++this.now);
      }
    },
    //获取购买记录
    getHistory(page) {
      if(page<1){        
        this.now = 1;
        return false;
      }
      if(page>this.last){
        this.now=  this.last;
        return false;
      }
      Axios.getAxios(
        "/api/strategyHistoryPc/normal",
        {
          page:page
        },
        {
          Authorization: "Bearer " + this.token
        }
      ).then(
        res => {          
          this.history = res.data.data.data;
          this.all = res.data.data.total;
        this.now = res.data.data.current_page;
        this.last = res.data.data.last_page;
        },
        err => {
          this.$message.error("请检查您的登录状态");
        }
      );
    }
  }
};
</script>

<style lang="stylus" scoped>
@import '~@/common/css/pager';
.list-wrap th {
  border: none;
  height: 40px;
  background-color: #E9E9E9;
  font-weight: bold;
  text-align: left;
  padding-left: 10px;
}
.list-wrap td {
  padding-top: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid #DBDBDB;
}
.iconfont {
  font-size: 20px !important;
  border: none !important;
  cursor: pointer;
}
.pagination ul {
  float: none;
}
</style>

